package com.czmh.etc.onlinepubsys.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.czmh.etc.onlinepubsys.json.mingchuang.JSONResult;
import com.czmh.etc.onlinepubsys.model.SysConfig;
import com.czmh.etc.onlinepubsys.services.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统信息配置表 前端控制器
 * </p>
 *
 * @author eric
 * @since 2021-11-18
 */
@RestController
@RequestMapping("/sysConfig")
@Api(tags = "SysConfigController", description = "系统信息配置")
public class SysConfigController {

    @Autowired
    SysConfigService sysConfigService;


    @ApiOperation(value = "根据配置key获取系统信息配置")
    @RequestMapping(value = "/queryByKey", method = RequestMethod.GET)
    @ResponseBody
    public JSONResult queryByKey(@RequestParam String key) {
        SysConfig sysConfig = sysConfigService.queryByKey(key);
        if(sysConfig != null) {
            JSONResult result = new JSONResult();
            result.setCode(JSONResult.SUCCESS);
            result.setRspData(JSON.toJSONString(sysConfig, SerializerFeature.WriteMapNullValue));
            return result;
        }else{
            JSONResult result = new JSONResult();
            result.setCode(JSONResult.FAIL);
            result.setMessage("系统配置不存在");
            return result;
        }
    }

}

